package com.example.naodian.controller;

import com.example.naodian.domain.dto.PageDto;
import com.example.naodian.domain.po.Warning;
import com.example.naodian.domain.vo.EegDataBlockVO;
import com.example.naodian.result.Result;
import com.example.naodian.service.IScheduledTasksService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/task")
@Api(tags = "定时任务相关接口")
@Slf4j
@RequiredArgsConstructor
@CrossOrigin(origins = "*") // 允许所有域名跨域请求
public class ScheduledTasksController {
    private final IScheduledTasksService scheduledTasksService;

    /**
     * 每间隔多少s查询一次预警信息
     * @param interval 间隔时间(默认5s)
     */
    @ApiOperation("每间隔多少s查询一次预警信息(默认5s)")
    @GetMapping("/startWarningTask")
    public void startWarningTask(@RequestParam(value = "interval", defaultValue = "5000") long interval){
        scheduledTasksService.startWarningTask(interval);
    }

    /**
     * 停止定时任务
     */
    @ApiOperation("停止定时任务")
    @GetMapping("/stopTask")
    public void stopTask(){
        scheduledTasksService.stopTask();
    }

    /**
     * 重置定时任务
     */
    @ApiOperation("重置定时任务")
    @GetMapping("/resetTask")
        public void resetTask(){scheduledTasksService.resetTask();}

    /**
     * 开始定时查询数据信息
     * @return 集合
     */
    @ApiOperation("开始定时查询脑电数据信息")
    @GetMapping("/startEegList")
    public void startEegList(@RequestParam(value = "interval", defaultValue = "5000") long interval,PageDto pageDto){
       scheduledTasksService.startEegList(interval,pageDto);
    }

}
